﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QLevelGenerator.Infrastructure
{
    public class Converter
    {
        private Random random = new Random();

        public string[][] ConvertMatrixToSymbols(int[][] matrix, string[] keySymbols, string[] otherSymbols)
        {
            var rows = matrix.GetUpperBound(0) + 1;
            var cols = rows;

            var outputData = new string[rows][];
            for (var rowIndex = 0; rowIndex < rows; rowIndex++)
            {
                outputData[rowIndex] = new string[cols];
            }

            for (var rowIndex = 0; rowIndex < rows; rowIndex++)
            {
                for (var colIndex = 0; colIndex < cols; colIndex++)
                {
                    var symbol = matrix[rowIndex][colIndex] == 0 
                        ? GetRandomElement(otherSymbols)
                        : GetRandomElement(keySymbols);

                    outputData[rowIndex][colIndex] = symbol;
                }
            }


            return outputData;
        }

        private string GetRandomElement(string[] symbols)
        {
            
            return symbols[random.Next(0, symbols.Length)];
        }
    }
}